<? 
	$title="Delete category"; 
	$pageid="5";
	$accessid="a00";
	require("required/dbconnect.php"); 
	require("required/function.php");
	
	
	
	
	if(isset($_POST['btnsubmit']))
	{
		require("../required/share_function.php");
		$id=$_POST['id'];
		
		
		restoreInventory($id);
		
		
		mysql_query("delete from os_bill_details where id=$id")or die(mysql_error());
		mysql_query("delete from os_bill_items where bid=$id")or die(mysql_error());
		
		mysql_query("delete from os_payment_record where bid=$id")or die(mysql_error());
		
		
		
		$chk_voucher=mysql_query("select * from os_discount_voucher_used where bill_id=$id");
		
		
		
		if(mysql_num_rows($chk_voucher)>0)
		{
			if(mysql_result($chk_voucher,0,"is_birthday_voucher")==0)
			{
				mysql_query("update os_discount_voucher_used set status=0, bill_id=0 where id=".mysql_result($chk_voucher,0,"id"))or die(mysql_error());
			}
			else
			{	
				mysql_query("delete from os_discount_voucher_used where bill_id=$id")or die(mysql_error());
			}
		}
		
		
		header("Location:order_view.php?action=2");
		
		
	}
	else
	{
	
		$enid=$_GET['id'];
	
	require("required/header.php");
?>
<table width="95%" cellpadding="2" cellspacing="1">
	
	<td valign="top" align="center">
	<table width="100%" >
	<tr>
		<td height="20" colspan="7" align="left" class="title" >Delete record</td>
	</tr>
	<tr>
		<td>Confirm to delete the order?</td>
	</tr>
	<tr>
		<td colspan="3" align="center">
		<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
		<input type="hidden" value="<?= $enid ?>" name="id">
		<input type="submit" value="Yes" name='btnsubmit' class="button">
		<input type="button" value="No" onClick="history.go(-1)" class="button">
		</form>
		</td>
	</tr>
	</table>
	</td>
 
</table>
<? } require("required/footer.php"); ?>
